package com.bidevalution.business.context;

/**
 * @author huyiqi
 * @date 2019/12/8
 */
public enum SexType {

    FEMALE(0, "女"),
    MALE(1, "男");

    SexType(int code, String name) {
        this.code = code;
        this.name = name;
    }

    public static int getCodeByName(String name) {
        int code = 0;
        SexType[] types = SexType.values();
        for(SexType type:types) {
            if(type.getName().equals(name)) {
                code = type.getCode();
            }
        }
        return code;
    }

    public static String getNameByCode(int code) {
        String name = FEMALE.getName();
        SexType[] types = SexType.values();
        for(SexType type:types) {
            if(type.getCode().equals(code)) {
                name = type.getName();
            }
        }
        return name;
    }

    public Integer getCode() {
        return code;
    }

    public String getName() {
        return name;
    }

    private Integer code;
    private String name;
}
